﻿using RockBus.DataContracts;
using System;
using System.Collections.Generic;
using System.ServiceModel.Channels;
using System.Threading.Tasks;
using System.Transactions;

namespace RockBus.Messages.Interfaces
{
    public interface IMessageContext
    {
        // ProcessingData
        ProcessingData ProcessingData { get; set; }

        // Message data
        IMessage RequestMessage { get; set; }

        IMessage ResponseMessage { get; set; }

        IMessage Message { get; }

        Transaction Transaction { get; }

        TransactionScope CreateTransactionScope(TransactionScopeOption option);

        ReceivePortInfo ReceivePortInfo { get; set; }

        EvaluationResult EvaluationResult { get; set; }

        // Publisher Completion
        TaskCompletionSource<Message> PublisherTcs { get; }

        // Subscriber data
        IEnumerable<RoutingHeader> RoutingHeaders { get; }

        void SetRoutingHeaders(IEnumerable<DeliveryInfo> deliveryInfos);

        void SetRoutingHeader(RoutingHeader routingHeader);

        bool IsPersistent();

        bool IsCorrelatedSubscriberEndpoint();

        bool ThrowOnNoSubscriptions { get; }

        Exception Exception { get; set; }

        void SetProperty(string key, object value);

        bool GetProperty(string key, out object value);

        // Lifetime
        bool Complete();

        void Abort();
    }
}